package com.filldream.fastboot.base.config;

/**
 * 数据源缓存
 * @author RickSun && iFillDream
 */
public class DbContextHolder {
    private static final ThreadLocal contextHolder = new ThreadLocal<>();
    /**
     * 设置数据源
     * @param dbName
     */
    public static void setDbType(String dbName) {
        contextHolder.set(dbName);
    }

    /**
     * 取得当前数据源
     * @return
     */
    public static String getDbType() {
        return (String) contextHolder.get();
    }

    /**
     * 清除上下文数据
     */
    public static void clearDbType() {
        contextHolder.remove();
    }
}
